package com.padakeji.android.pworks.example.nav;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.padakeji.android.pworks.example.R;
import com.padakeji.android.pworks.ui.UIHelper;

/**
 * Created by AtanL on 2015/9/23.
 */
public class NavTestFragment extends Fragment {

    private static final String ARGS_KEY_POSITION = "ARGS_KEY_POSITION";

    private int position;

    public static NavTestFragment getNavTestFragment(int p) {
        NavTestFragment f = new NavTestFragment();
        Bundle b = new Bundle();
        b.putInt(ARGS_KEY_POSITION, p);
        f.setArguments(b);
        return f;
    }


    private TextView tv;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_nav_test, container, false);

        tv = (TextView) v.findViewById(R.id.fragment_nav_text_flag);
        tv.setClickable(true);

        Bundle b = getArguments();
        if (b != null) {
            position = b.getInt(ARGS_KEY_POSITION);
        }

        tv.setText(position + "");
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new UIHelper(getActivity()).showToast("" + position);
            }
        });
        return v;
    }

}
